<template>
    <div>
        <buy-vip :visible="showVip" :code="code" @visibleChange="onShow"/>
    </div>
</template>
<script>
import BuyVip from '@/views/user/module-vip/buy-vip';
import wxConfig from '@/vue/mixin/wx-config';

export default {
    mixins: [wxConfig],
    props: {
        code: String
    },

    data(){
        return {
            showVip: false,
        }
    },

    created() {
        this.wxconfig();
        const user = this.getUser();
        if (user.isVip) {
            this.$toast('您已经是VIP会员了');
            setTimeout(() => {
                this.$router.push({name: 'home'});
            }, 1500);
        } else {
            this.showVip = true;
        }
    },

    methods: {
        onShow(show) {
            if (!show) {
                this.showVip = false;
                this.$router.push({name: 'home'});
            }
        }
    },

    components: {
        [BuyVip.name]: BuyVip
    }
}

</script>
